﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using eCitizen.eAlerts.Constants;
using eCitizen.DataContracts;
using eCitizen.DataAccess;
using eCitizen.eAlerts.Utilities;

namespace eCitizen.eAlerts.Utilities
{
    public class ServiceHelper
    {
        protected static int _batchInstanceId;
        protected static int _batchServiceInstanceId;
        protected BatchJobLoggingService _batchJobLoggingService;

        public ServiceHelper()
        {
            _batchJobLoggingService = new BatchJobLoggingService();
        }

        public void StartBatchJobWatch(ServiceType currentServiceType)
        {
            int serviceType = (int)currentServiceType;
            _batchInstanceId = _batchJobLoggingService.StartBatchJobWatch(serviceType, DateTime.Now);
        }
        public void StopBatchJobWatch()
        {
            _batchJobLoggingService.StopBatchJobWatch(_batchInstanceId, DateTime.Now);
        }

        public void StartServiceInstanceWatch(string agency, string service)
        {
            _batchServiceInstanceId = _batchJobLoggingService.StartServiceInstanceWatch(_batchInstanceId, agency, service, DateTime.Now);
        }

        public void StopServiceInstanceWatch()
        {
            _batchJobLoggingService.StopServiceInstanceWatch(_batchServiceInstanceId, DateTime.Now);
        }

        public List<RequestEntry> LogAlertServiceRequests(List<RequestEntry> subscriptionRequest)
        {
            return _batchJobLoggingService.LogAlertServiceRequests(_batchServiceInstanceId, subscriptionRequest);
        }

        public void LogSubscribersForBroadcast(List<Subscriber> subscriberList)
        {
            _batchJobLoggingService.LogSubscribersForBroadcast(_batchServiceInstanceId, subscriberList);
        }

        public void LogeAlertFileToProcess(string fileName, bool isRequestFile, DateTime processingDate)
        {
            _batchJobLoggingService.LogeAlertFileToProcess(_batchServiceInstanceId, fileName, isRequestFile, processingDate);
        }

        public int GetRunningFileNo(ServiceType currentServiceType, DateTime processingDate)
        {
            return _batchJobLoggingService.GetRunningFileNo((int)currentServiceType, processingDate);
        }
    }
}
